package com.ruoyi.project.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.project.domain.BeamRealtimeHis;
import com.ruoyi.project.service.IBeamRealtimeHisService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 浆纱历史记录Controller
 * 
 * @author ruoyi
 * @date 2021-11-28
 */
@RestController
@RequestMapping("/mes/history")
public class BeamRealtimeHisController extends BaseController
{
    @Autowired
    private IBeamRealtimeHisService beamRealtimeHisService;

    /**
     * 查询浆纱历史记录列表
     */
    @PreAuthorize("@ss.hasPermi('mes:history:list')")
    @GetMapping("/list")
    public TableDataInfo list(BeamRealtimeHis beamRealtimeHis)
    {
        startPage();
        List<BeamRealtimeHis> list = beamRealtimeHisService.selectBeamRealtimeHisList(beamRealtimeHis);
        return getDataTable(list);
    }

    /**
     * 导出浆纱历史记录列表
     */
    @PreAuthorize("@ss.hasPermi('mes:history:export')")
    @Log(title = "浆纱历史记录", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BeamRealtimeHis beamRealtimeHis)
    {
        List<BeamRealtimeHis> list = beamRealtimeHisService.selectBeamRealtimeHisList(beamRealtimeHis);
        ExcelUtil<BeamRealtimeHis> util = new ExcelUtil<BeamRealtimeHis>(BeamRealtimeHis.class);
        return util.exportExcel(list, "浆纱历史记录数据");
    }

    /**
     * 获取浆纱历史记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('mes:history:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(beamRealtimeHisService.selectBeamRealtimeHisById(id));
    }

    /**
     * 新增浆纱历史记录
     */
    @PreAuthorize("@ss.hasPermi('mes:history:add')")
    @Log(title = "浆纱历史记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BeamRealtimeHis beamRealtimeHis)
    {
        return toAjax(beamRealtimeHisService.insertBeamRealtimeHis(beamRealtimeHis));
    }

    /**
     * 修改浆纱历史记录
     */
    @PreAuthorize("@ss.hasPermi('mes:history:edit')")
    @Log(title = "浆纱历史记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BeamRealtimeHis beamRealtimeHis)
    {
        return toAjax(beamRealtimeHisService.updateBeamRealtimeHis(beamRealtimeHis));
    }

    /**
     * 删除浆纱历史记录
     */
    @PreAuthorize("@ss.hasPermi('mes:history:remove')")
    @Log(title = "浆纱历史记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(beamRealtimeHisService.deleteBeamRealtimeHisByIds(ids));
    }
}
